package game;

import java.io.Serializable;

public class Card implements Serializable {
	private static final long serialVersionUID = 6596751888509246155L;
	private String suit;
	private int value;
	/**
	 * Makes a new card with described suit and value.
	 * When suit is "X" and value 1, then it is reversed card.
	 * Other suits are: "SPADES","DIAMONDS","CLUBS","HEARTS"
	 * @param suit The suit of the card
	 * @param value Value of the card
	 */
	public Card(String suit, int value){
		this.suit = suit;
		this.value = value;
	}
	/**
	 * @return the suit of the card
	 */
	public synchronized String getSuit() {
		return suit;
	}
	/**
	 * @return the value of he card
	 */
	public synchronized int getValue() {
		return value;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((suit == null) ? 0 : suit.hashCode());
		result = prime * result + value;
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Card other = (Card) obj;
		if (suit == null) {
			if (other.suit != null)
				return false;
		} else if (!suit.equals(other.suit))
			return false;
		if (value != other.value)
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "Card [suit=" + suit + ", value=" + value + "]";
	}
	
}
